package main

import "fmt"

// 类和属性名首字母大写，可以其它包访问
// 也就是大写是共有，小写是私有
type Hero struct{
    Name string
    Age int
    Level int
}

func (this Hero) Show(){
    fmt.Println("Name = ",this.Name)
}

// 需要加引用才能进行改变
func (this *Hero) SetName(name string){
    this.Name = name
}

func (this Hero) GetName() string{
    return this.Name
}

func main(){
    //hero := Hero{Name:"JackyChen",Age:18,Level:1}
    hero := Hero{"JackyChen",18,1}
    hero.Show()

    hero.SetName("cxhblog")
    hero.Show()
}